﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using System.IO;
using System.Diagnostics;

namespace DragonAgeConsoleTrainer
{
	public partial class AboutForm : Form
	{
		private Stream htmlStream = null;

		public AboutForm()
		{
			InitializeComponent();
		}

		private void AboutForm_Load(object sender, EventArgs e)
		{
			htmlStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("DragonAgeConsoleTrainer.License.htm");
			webBrowser.DocumentStream = htmlStream;
		}

		protected override void OnClosing(CancelEventArgs e)
		{
			base.OnClosing(e);

			if (htmlStream != null)
			{
				htmlStream.Dispose();
				htmlStream = null;
			}
		}

		private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
		{
			//	Rather than having all the links open up a New IE Window just run the Url and allow the
			//	user's default Web Browser Open it
			foreach (HtmlElement el in webBrowser.Document.GetElementsByTagName("a"))
			{
				string href = el.GetAttribute("href");
				el.AttachEventHandler("onclick", new EventHandler(delegate(object clickSender, EventArgs args)
				{
					Process.Start(href);
				}));
			}
		}
	}
}
